package com.bang.study;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;

import java.util.Date;
import java.util.LinkedHashMap;


public class test002 {

	private static final String[] ips = {"192.168.96.172","192.168.96.173"};


	public static void main(String[] args){

		cpu c = new cpu();
		disk disk = new disk();
		dynamic dynamic = new dynamic();
		file file = new file();
		memory memory = new memory();
		network network = new network();
		onlinestatus onlinestatus = new onlinestatus();
		process process = new process();
		software software = new software();
		getStatic getStatic = new getStatic();

        Thread t1 = new Thread(c);
        Thread t2 = new Thread(disk);
        Thread t3 = new Thread(dynamic);
        Thread t4 = new Thread(file);
        Thread t5 = new Thread(memory);
        Thread t6 = new Thread(network);
        Thread t7 = new Thread(onlinestatus);
        Thread t8 = new Thread(process);
        Thread t9 = new Thread(software);
        Thread t10 = new Thread(getStatic);

        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
        t6.start();
        t7.start();
        t8.start();
        t9.start();
        t10.start();
	}

	//cpu信息
	static class cpu implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"3\",\"timestamp\":\"1615935426\",\"value\":[{\"cpuIndex\":\"0\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3177.347900\",\"cpuRate\":\"99.005025\"},{\"cpuIndex\":\"1\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3073.066895\",\"cpuRate\":\"0.502513\"},{\"cpuIndex\":\"2\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3194.059082\",\"cpuRate\":\"2.500000\"},{\"cpuIndex\":\"3\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3191.548096\",\"cpuRate\":\"91.005025\"},{\"cpuIndex\":\"4\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3188.285889\",\"cpuRate\":\"1.492537\"},{\"cpuIndex\":\"5\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3146.465088\",\"cpuRate\":\"2.985075\"},{\"cpuIndex\":\"6\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3180.385010\",\"cpuRate\":\"0.502513\"},{\"cpuIndex\":\"7\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3182.501953\",\"cpuRate\":\"5.000000\"},{\"cpuIndex\":\"8\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3194.062988\",\"cpuRate\":\"3.517588\"},{\"cpuIndex\":\"9\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3194.075928\",\"cpuRate\":\"90.502513\"},{\"cpuIndex\":\"10\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3193.788086\",\"cpuRate\":\"1.980198\"},{\"cpuIndex\":\"11\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3194.017090\",\"cpuRate\":\"91.507538\"},{\"cpuIndex\":\"12\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3193.641113\",\"cpuRate\":\"76.467662\"},{\"cpuIndex\":\"13\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3194.079102\",\"cpuRate\":\"92.010050\"},{\"cpuIndex\":\"14\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3189.864014\",\"cpuRate\":\"92.000000\"},{\"cpuIndex\":\"15\",\"cpuName\":\"Hygon C86 3280  8-core Processor\",\"cpuCores\":\"16\",\"cpuFreq\":\"3186.573975\",\"cpuRate\":\"91.005025\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("cpu信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//磁盘信息
	static class disk implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"6\",\"timestamp\":\"1615935272\",\"value\":[{\"diskName\":\"sda\",\"diskSn\":\"\",\"readNum\":\"0.132718\",\"writeNum\":\"21.630640\",\"kbRead\":\"5.930226\",\"kbWrtn\":\"218.819885\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("磁盘信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//动态信息
	static class dynamic implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"2\",\"timestamp\":\"1615935272\",\"value\":[{\"sysUptime\":\"592196\",\"sysInstallTime\":\"1612179969\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("动态信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//文件分区
	static class file implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"5\",\"timestamp\":\"1615935424\",\"value\":[{\"fileSys\":\"/sys\",\"fileType\":\"sysfs\",\"partTotal\":\"100.000000\",\"partFree\":\"0.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/proc\",\"fileType\":\"proc\",\"partTotal\":\"100.000000\",\"partFree\":\"0.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/dev\",\"fileType\":\"devtmpfs\",\"partTotal\":\"16408316.000000\",\"partFree\":\"1000.000000\",\"partInodeNum\":\"4102079\",\"partInodeFree\":\"4101573\"},{\"fileSys\":\"/sys/kernel/security\",\"fileType\":\"securityfs\",\"partTotal\":\"100.000000\",\"partFree\":\"10.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/dev/shm\",\"fileType\":\"tmpfs\",\"partTotal\":\"16425304.000000\",\"partFree\":\"20000.000000\",\"partInodeNum\":\"4106326\",\"partInodeFree\":\"4106321\"},{\"fileSys\":\"/dev/pts\",\"fileType\":\"devpts\",\"partTotal\":\"98.000000\",\"partFree\":\"15.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/run\",\"fileType\":\"tmpfs\",\"partTotal\":\"16425304.000000\",\"partFree\":\"30000.000000\",\"partInodeNum\":\"4106326\",\"partInodeFree\":\"4105132\"},{\"fileSys\":\"/sys/fs/cgroup\",\"fileType\":\"tmpfs\",\"partTotal\":\"16425304.000000\",\"partFree\":\"50000.000000\",\"partInodeNum\":\"4106326\",\"partInodeFree\":\"4106309\"},{\"fileSys\":\"/sys/fs/cgroup/systemd\",\"fileType\":\"cgroup\",\"partTotal\":\"99.000000\",\"partFree\":\"3.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/pstore\",\"fileType\":\"pstore\",\"partTotal\":\"97.000000\",\"partFree\":\"2.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/firmware/efi/efivars\",\"fileType\":\"efivarfs\",\"partTotal\":\"105.000000\",\"partFree\":\"10.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/bpf\",\"fileType\":\"bpf\",\"partTotal\":\"111.000000\",\"partFree\":\"11.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/net_cls,net_prio\",\"fileType\":\"cgroup\",\"partTotal\":\"222.000000\",\"partFree\":\"22.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/blkio\",\"fileType\":\"cgroup\",\"partTotal\":\"333.000000\",\"partFree\":\"33.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/memory\",\"fileType\":\"cgroup\",\"partTotal\":\"332.000000\",\"partFree\":\"32.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/pids\",\"fileType\":\"cgroup\",\"partTotal\":\"258.000000\",\"partFree\":\"46.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/cpuset\",\"fileType\":\"cgroup\",\"partTotal\":\"12.000000\",\"partFree\":\"1.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/cpu,cpuacct\",\"fileType\":\"cgroup\",\"partTotal\":\"654.000000\",\"partFree\":\"22.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/rdma\",\"fileType\":\"cgroup\",\"partTotal\":\"121.000000\",\"partFree\":\"12.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/hugetlb\",\"fileType\":\"cgroup\",\"partTotal\":\"2323.000000\",\"partFree\":\"12.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/freezer\",\"fileType\":\"cgroup\",\"partTotal\":\"655.000000\",\"partFree\":\"34.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/devices\",\"fileType\":\"cgroup\",\"partTotal\":\"789.000000\",\"partFree\":\"98.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/fs/cgroup/perf_event\",\"fileType\":\"cgroup\",\"partTotal\":\"80.000000\",\"partFree\":\"8.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/kernel/config\",\"fileType\":\"configfs\",\"partTotal\":\"66.000000\",\"partFree\":\"6.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/\",\"fileType\":\"ext4\",\"partTotal\":\"74828672.000000\",\"partFree\":\"500000.000000\",\"partInodeNum\":\"4792320\",\"partInodeFree\":\"4562768\"},{\"fileSys\":\"/sys/fs/selinux\",\"fileType\":\"selinuxfs\",\"partTotal\":\"645.000000\",\"partFree\":\"45.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/proc/sys/fs/binfmt_misc\",\"fileType\":\"autofs\",\"partTotal\":\"231.000000\",\"partFree\":\"11.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/dev/mqueue\",\"fileType\":\"mqueue\",\"partTotal\":\"754.000000\",\"partFree\":\"34.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/dev/hugepages\",\"fileType\":\"hugetlbfs\",\"partTotal\":\"322.000000\",\"partFree\":\"44.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/sys/kernel/debug\",\"fileType\":\"debugfs\",\"partTotal\":\"65464654.000000\",\"partFree\":\"45455.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/proc/sys/fs/binfmt_misc\",\"fileType\":\"binfmt_misc\",\"partTotal\":\"655.000000\",\"partFree\":\"55.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/boot\",\"fileType\":\"ext4\",\"partTotal\":\"487634.000000\",\"partFree\":\"2000.000000\",\"partInodeNum\":\"128016\",\"partInodeFree\":\"127925\"},{\"fileSys\":\"/home\",\"fileType\":\"ext4\",\"partTotal\":\"45888356.000000\",\"partFree\":\"500000.000000\",\"partInodeNum\":\"2932736\",\"partInodeFree\":\"2929354\"},{\"fileSys\":\"/recovery\",\"fileType\":\"ext4\",\"partTotal\":\"45888356.000000\",\"partFree\":\"282884.000000\",\"partInodeNum\":\"2932736\",\"partInodeFree\":\"2932693\"},{\"fileSys\":\"/var/log\",\"fileType\":\"ext4\",\"partTotal\":\"45888356.000000\",\"partFree\":\"98987.000000\",\"partInodeNum\":\"2932736\",\"partInodeFree\":\"2905549\"},{\"fileSys\":\"/boot/efi\",\"fileType\":\"vfat\",\"partTotal\":\"204580.000000\",\"partFree\":\"9875.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/var/lib/nfs/rpc_pipefs\",\"fileType\":\"rpc_pipefs\",\"partTotal\":\"12.000000\",\"partFree\":\"2.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/run/user/42\",\"fileType\":\"tmpfs\",\"partTotal\":\"3285060.000000\",\"partFree\":\"54545.000000\",\"partInodeNum\":\"4106326\",\"partInodeFree\":\"4106311\"},{\"fileSys\":\"/sys/kernel/debug/tracing\",\"fileType\":\"tracefs\",\"partTotal\":\"99.000000\",\"partFree\":\"6.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/misc\",\"fileType\":\"autofs\",\"partTotal\":\"963.000000\",\"partFree\":\"25.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/net\",\"fileType\":\"autofs\",\"partTotal\":\"6720.000000\",\"partFree\":\"120.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/run/user/0\",\"fileType\":\"tmpfs\",\"partTotal\":\"3285060.000000\",\"partFree\":\"3000.000000\",\"partInodeNum\":\"4106326\",\"partInodeFree\":\"4106297\"},{\"fileSys\":\"/sys/fs/fuse/connections\",\"fileType\":\"fusectl\",\"partTotal\":\"140.000000\",\"partFree\":\"14.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"},{\"fileSys\":\"/run/user/0/gvfs\",\"fileType\":\"fuse.gvfsd-fuse\",\"partTotal\":\"230.000000\",\"partFree\":\"34.000000\",\"partInodeNum\":\"0\",\"partInodeFree\":\"0\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("文件分区信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//内存信息
	static class memory implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"4\",\"timestamp\":\"1615935272\",\"value\":[{\"memTotal\":\"22795408\",\"memFree\":\"1795408\",\"memAvailable\":\"10\",\"buffers\":\"1054540\",\"cached\":\"9973880\",\"swapTotal\":\"16491516\",\"swapFree\":\"20\",\"swapCached\":\"0\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("内存信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//网络接口信息
	static class network implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"7\",\"timestamp\":\"1615935272\",\"value\":[{\"ifIndex\":\"2\",\"ifDescr\":\"gl_net\",\"ifType\":\"1\",\"ifMtu\":\"1500\",\"ifSpeed\":\"520000\",\"ifIp\":\"192.168.96.177\",\"ifSubmask\":\"255.255.255.0\",\"ifGateway\":\"10.20.0.255\",\"ifPhysaddr\":\"64:81:13:b3:a1:3a\",\"ifAdminStatus\":\"2\",\"ifOperStatus\":\"2\",\"ifInOctets\":\"11466257594\",\"ifInUcastpkts\":\"61685401\",\"ifInNucastpkts\":\"3595385\",\"ifInDiscards\":\"22222\",\"ifInErrors\":\"4500\",\"ifOutOctets\":\"179993333828\",\"ifOutUcastpkts\":\"66064155\",\"ifOutNucastpkts\":\"0\",\"ifOutDiscards\":\"20000\",\"ifOutErrors\":\"22342\",\"ifInIcmps\":\"6737592\",\"ifOutIcmps\":\"6764424\"},{\"ifIndex\":\"19\",\"ifDescr\":\"bm_net\",\"ifType\":\"1\",\"ifMtu\":\"1500\",\"ifSpeed\":\"20000\",\"ifIp\":\"10.30.0.71\",\"ifSubmask\":\"255.255.255.0\",\"ifGateway\":\"10.30.0.255\",\"ifPhysaddr\":\"64:91:13:b3:a1:3a\",\"ifAdminStatus\":\"2\",\"ifOperStatus\":\"2\",\"ifInOctets\":\"11563728\",\"ifInUcastpkts\":\"1195\",\"ifInNucastpkts\":\"173544\",\"ifInDiscards\":\"32222\",\"ifInErrors\":\"14500\",\"ifOutOctets\":\"655062\",\"ifOutUcastpkts\":\"9273\",\"ifOutNucastpkts\":\"0\",\"ifOutDiscards\":\"30000\",\"ifOutErrors\":\"32342\",\"ifInIcmps\":\"6737592\",\"ifOutIcmps\":\"6764424\"},{\"ifIndex\":\"3\",\"ifDescr\":\"enp5s0\",\"ifType\":\"1\",\"ifMtu\":\"1500\",\"ifSpeed\":\"120000\",\"ifIp\":\"\",\"ifSubmask\":\"\",\"ifGateway\":\"\",\"ifPhysaddr\":\"08:3a:88:74:2a:e7\",\"ifAdminStatus\":\"1\",\"ifOperStatus\":\"1\",\"ifInOctets\":\"711084\",\"ifInUcastpkts\":\"373\",\"ifInNucastpkts\":\"11347\",\"ifInDiscards\":\"42222\",\"ifInErrors\":\"24500\",\"ifOutOctets\":\"50609\",\"ifOutUcastpkts\":\"303\",\"ifOutNucastpkts\":\"0\",\"ifOutDiscards\":\"120000\",\"ifOutErrors\":\"42342\",\"ifInIcmps\":\"6737592\",\"ifOutIcmps\":\"6764424\"},{\"ifIndex\":\"1\",\"ifDescr\":\"lo\",\"ifType\":\"772\",\"ifMtu\":\"65536\",\"ifSpeed\":\"220000\",\"ifIp\":\"127.0.0.1\",\"ifSubmask\":\"255.0.0.0\",\"ifGateway\":\"\",\"ifPhysaddr\":\"\",\"ifAdminStatus\":\"2\",\"ifOperStatus\":\"2\",\"ifInOctets\":\"6309814677\",\"ifInUcastpkts\":\"12915097\",\"ifInNucastpkts\":\"0\",\"ifInDiscards\":\"11110\",\"ifInErrors\":\"34500\",\"ifOutOctets\":\"6309814677\",\"ifOutUcastpkts\":\"12915097\",\"ifOutNucastpkts\":\"0\",\"ifOutDiscards\":\"220000\",\"ifOutErrors\":\"52342\",\"ifInIcmps\":\"6737592\",\"ifOutIcmps\":\"6764424\"},{\"ifIndex\":\"7\",\"ifDescr\":\"virbr0-nic\",\"ifType\":\"1\",\"ifMtu\":\"1500\",\"ifSpeed\":\"320000\",\"ifIp\":\"\",\"ifSubmask\":\"\",\"ifGateway\":\"\",\"ifPhysaddr\":\"52:54:00:3e:60:49\",\"ifAdminStatus\":\"2\",\"ifOperStatus\":\"2\",\"ifInOctets\":\"0\",\"ifInUcastpkts\":\"0\",\"ifInNucastpkts\":\"0\",\"ifInDiscards\":\"2222\",\"ifInErrors\":\"44500\",\"ifOutOctets\":\"0\",\"ifOutUcastpkts\":\"0\",\"ifOutNucastpkts\":\"0\",\"ifOutDiscards\":\"120000\",\"ifOutErrors\":\"2342\",\"ifInIcmps\":\"6737592\",\"ifOutIcmps\":\"6764424\"},{\"ifIndex\":\"6\",\"ifDescr\":\"virbr0\",\"ifType\":\"1\",\"ifMtu\":\"1500\",\"ifSpeed\":\"420000\",\"ifIp\":\"192.168.122.1\",\"ifSubmask\":\"255.255.255.0\",\"ifGateway\":\"192.168.122.255\",\"ifPhysaddr\":\"52:54:00:3e:60:49\",\"ifAdminStatus\":\"2\",\"ifOperStatus\":\"2\",\"ifInOctets\":\"0\",\"ifInUcastpkts\":\"0\",\"ifInNucastpkts\":\"0\",\"ifInDiscards\":\"12222\",\"ifInErrors\":\"54500\",\"ifOutOctets\":\"0\",\"ifOutUcastpkts\":\"0\",\"ifOutNucastpkts\":\"0\",\"ifOutDiscards\":\"201000\",\"ifOutErrors\":\"12342\",\"ifInIcmps\":\"6737592\",\"ifOutIcmps\":\"6764424\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("网络接口信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//在线状态
	static class onlinestatus implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"1000\",\"timestamp\":\"1615932491\",\"value\":[]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("在线情况已发送~~~");

					Thread.sleep(10*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//进程信息
	static class process implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"8\",\"timestamp\":\"1615932481\",\"value\":[{\"procId\":\"7715\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7717\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7719\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7720\",\"procName\":\"sysmptmonitor\",\"procPath\":\"./sysmptmonitor\",\"procState\":\"0\",\"procCpu\":\"0.031250\",\"procMem\":\"0.019726\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"7721\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7722\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7723\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7724\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7725\",\"procName\":\"\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"\",\"ifOutOctets\":\"\"},{\"procId\":\"7937\",\"procName\":\"chronyd\",\"procPath\":\"/usr/sbin/chronyd\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.007756\",\"ifInOctets\":\"20480\",\"ifOutOctets\":\"0\"},{\"procId\":\"9002\",\"procName\":\"ibus-engine-lib\",\"procPath\":\"/usr/libexec/ibus-engine-libpinyin\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.038818\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"9003\",\"procName\":\"platform-python\",\"procPath\":\"/usr/libexec/platform-python\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.090884\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"4096\"},{\"procId\":\"11046\",\"procName\":\"kworker/9\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"11775\",\"procName\":\"kworker/14\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"11948\",\"procName\":\"gdm-session-wor\",\"procPath\":\"gdm-session-worker [pam/gdm-password]\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.047719\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"12442\",\"procName\":\"kworker/1\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"12694\",\"procName\":\"kworker/0\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"12959\",\"procName\":\"kworker/13\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"14182\",\"procName\":\"kworker/11\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"15419\",\"procName\":\"sysmptmonitor\",\"procPath\":\"/opt/sysmpt/monitor/szy/client/bin/sysmptmonitor\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.011336\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"15435\",\"procName\":\"systemd\",\"procPath\":\"/usr/lib/systemd/systemd\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.028858\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"4096\"},{\"procId\":\"15449\",\"procName\":\"(sd-pam)\",\"procPath\":\"(sd-pam)\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.019019\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"15677\",\"procName\":\"java\",\"procPath\":\"/usr/bin/java\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"2.505865\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"130973696\"},{\"procId\":\"15804\",\"procName\":\"kworker/15\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"15806\",\"procName\":\"kworker/2\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"16097\",\"procName\":\"kworker/6\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"16269\",\"procName\":\"kworker/10\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"16904\",\"procName\":\"kworker/u32\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"17045\",\"procName\":\"bl_notify\",\"procPath\":\"/usr/bin/bl_notify\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.021552\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"17350\",\"procName\":\"kworker/12\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"17616\",\"procName\":\"java\",\"procPath\":\"java\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.871899\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"244482048\"},{\"procId\":\"18108\",\"procName\":\"gdm-session-wor\",\"procPath\":\"gdm-session-worker [pam/gdm-password]\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.046915\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"20314\",\"procName\":\"kworker/4\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"3338240\"},{\"procId\":\"21817\",\"procName\":\"pulseaudio\",\"procPath\":\"/usr/bin/pulseaudio\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.026849\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"8192\"},{\"procId\":\"21987\",\"procName\":\"kworker/8\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.031250\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"22066\",\"procName\":\"kworker/15\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"22225\",\"procName\":\"gdm-session-wor\",\"procPath\":\"gdm-session-worker [pam/gdm-password]\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.047670\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"22985\",\"procName\":\"kworker/7\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"23220\",\"procName\":\"kworker/5\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"23376\",\"procName\":\"sssd_kcm\",\"procPath\":\"/usr/libexec/sssd/sssd_kcm\",\"procState\":\"2\",\"procCpu\":\"0.031250\",\"procMem\":\"0.097557\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"23902\",\"procName\":\"mysqld\",\"procPath\":\"/usr/libexec/mysqld\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.502481\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"4300800\"},{\"procId\":\"23950\",\"procName\":\"kworker/11\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"24206\",\"procName\":\"kworker/12\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"24372\",\"procName\":\"java\",\"procPath\":\"/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.nfs.x86_64/jre/bin/java\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"9.563622\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"252493824\"},{\"procId\":\"24539\",\"procName\":\"kworker/8\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"25481\",\"procName\":\"kworker/9\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"25986\",\"procName\":\"soc_net_client\",\"procPath\":\"/opt/SSCard/AQGL/bin/soc_net_client\",\"procState\":\"2\",\"procCpu\":\"0.000000\",\"procMem\":\"0.020736\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"7598080\"},{\"procId\":\"27482\",\"procName\":\"kworker/1\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"27493\",\"procName\":\"kworker/14\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"27673\",\"procName\":\"kworker/7\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"27675\",\"procName\":\"kworker/5\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"29044\",\"procName\":\"kworker/6\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"30028\",\"procName\":\"kworker/3\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"30523\",\"procName\":\"kworker/4\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"30827\",\"procName\":\"kworker/u32\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"},{\"procId\":\"32391\",\"procName\":\"kworker/2\",\"procPath\":\"\",\"procState\":\"0\",\"procCpu\":\"0.000000\",\"procMem\":\"0.000000\",\"ifInOctets\":\"0\",\"ifOutOctets\":\"0\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("进程信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//软件信息
	static class software implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"15\",\"timestamp\":\"1615935272\",\"value\":[{\"softPkgName\":\"managercenter\",\"softPkgVersion\":\"3.0.0.25404-r5\"},{\"softPkgName\":\"sysmptmonitorszyclient\",\"softPkgVersion\":\"1.1-1.el7\"},{\"softPkgName\":\"sysmptmonitorszyserver\",\"softPkgVersion\":\"2.0-1.el7\"},{\"softPkgName\":\"zyjmonitor\",\"softPkgVersion\":\"2.0.0.3-1.el7.centos\"},{\"softPkgName\":\"all-sh\",\"softPkgVersion\":\"1.0-1.el7.centos\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("软件信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}

	//静态信息
	static class getStatic implements Runnable {

		public void run(){
			while(true){
				try {
					String json = "{\"ip\":\"192.168.96.177\",\"type\":\"6\",\"index\":\"1\",\"timestamp\":\"1615935272\",\"value\":[{\"uniqueIdent\":\"0200042009500080\",\"productName\":\"涉密专用服务器111\",\"productModel\":\"H620-G30S3\",\"manufacturer\":\"Sugon\",\"cpuInfo\":\" Hygon C86 3280  8-core Processor(8核)\",\"diskSn\":\"201214240G09877\",\"biosVersion\":\" Byosoft BA.4.998.200703.SGA\",\"sysName\":\"中科方德高可信服务器操作系统(涉密专用版SVS2.16.2)\",\"sysArch\":\"x86_64\",\"sysBits\":\"64\",\"sysVersion\":\"SVS2.16.2.FD.8686.210118\",\"coreVersion\":\"8.20.113-5.nfs4sv.27.x86_64\",\"netNum\":\"6\",\"cpuNum\":\"16\",\"socVersion\":\"SR1.8888.33336.201226_test\",\"ioVersion\":\"IO-04.2.04.02.048887\"}]}";

					for (String ip : ips) {

						String new_text =  updateData(json,ip);

						//修改发送的ip和端口
						UdpTool.sendToUDP(new_text,"192.168.96.177",3333);

					}

					System.out.println("静态信息已发送~~~");

					Thread.sleep(30*1000);  //每1分钟轮询一次

				} catch (InterruptedException e) {
						e.printStackTrace();
				}
			}
		}
	}


	private static  String updateData(String json,String ip) {

		LinkedHashMap<String, Object> js = JSON.parseObject(json,LinkedHashMap.class,Feature.OrderedField);
		JSONObject jsonObject=new JSONObject(true);
		jsonObject.putAll(js);
		//修改ip
		jsonObject.put("ip", ip);//替换key对应的值
		//自动修改时间
		jsonObject.put("timestamp", new Date().getTime()/1000+"");//替换key对应的值

		return jsonObject.toJSONString();
	}
}
